<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let strings = prompt("请输入一串字符");
        chars(strings);
        // let t = "c";
        // let p = t.charCodeAt();
        // document.write(p);
        function chars(str) {
            let capitals = 0; //大写数目
            let lowers = 0; //小写数目
            let numbers = 0 // 数字数目
            let others = 0; //其他符号数目
            for (let i = 0; i < str.length; i++) {
                let p = str[i];
                p = p.charCodeAt();

                if (p >= 48 && p <= 57) {
                    numbers++;
                } else if (p >= 65 && p <= 90) {
                    capitals++;
                } else if (p >= 97 && p <= 122) {
                    lowers++;
                } else {
                    others++;
                }

            }

            document.write("该字符串包含的大写字母为" + capitals + "个,<br/>小写字母为" + lowers + "个,<br>数字字符为" + numbers + "个,<br /> 其他字符为" + others + "个。");
        }
    </script>

</body>

</html>